package cn.xerllent.wxtp.handler;

import java.util.Map;

import org.springframework.stereotype.Component;

import lombok.val;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceOnTpImpl;
import me.chanjar.weixin.cp.bean.message.WxCpTpXmlMessage;
import me.chanjar.weixin.cp.bean.message.WxCpXmlOutMessage;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
import me.chanjar.weixin.cp.tp.service.WxCpTpService;

/**
 * 家校通讯录变更事件处理器.
 *
 */
@Component
public class SchContactHandler extends AbstractHandler {

  @Override
  public WxCpXmlOutMessage handle(WxCpTpXmlMessage wxMessage, Map<String, Object> context, WxCpTpService wxCpTpService,
                                  WxSessionManager sessionManager) {
    String content = "收到通讯录变更事件，内容：";
    
    //第三方服务商service基础上构造授权企业service的代码api
    
    WxCpService wxCpService = new WxCpServiceOnTpImpl(wxCpTpService);
    
    

    val configStorage = new WxCpDefaultConfigImpl();
    configStorage.setCorpId(wxMessage.getAuthCorpId());
    configStorage.setCorpSecret("permanentCode");//从数据库中查找出permanentCode
    configStorage.setAgentId(null); //生成jssdk sign时需要
    
    wxCpService.setWxCpConfigStorage(configStorage);
    
//    wxCpService.getTagService().listAll()
    
    
    
//    wxCpService.createJsapiSignature("url");

    return null;
  }

}
